var a = getApp(), t = require("../../utils/util.js");

Page({
    data: {
        array: [ "白羊座（3.21-4.19)", "金牛座（4.20-5.20)", "双子座（5.21-6.21)", "巨蟹座（6.22-7.22)", "狮子座（7.23-8.22)", "处女座（8.23-9.22)", "天秤座（9.23-10.23)", "天蝎座（10.24-11.22)", "射手座（11.23-12.21)", "摩羯座（12.22-1.19)", "水瓶座（1.20-2.18)", "双鱼座（2.19-3.20)" ],
        xz: [ "白羊", "金牛", "双子", "巨蟹", "狮子", "处女", "天秤", "天蝎", "射手", "摩羯", "水瓶", "双鱼" ],
        maleid: 0,
        smaleid: 0,
        topNum: a.globalData.topNum
    },
    onLoad: function(a) {
        var t = this, o = a.maleid;
        if (o) {
            for (var n = 0; n < t.data.topNum.length; n++) o == t.data.topNum[n] && (o = n);
            t.setData({
                maleid: o,
                smaleid: o
            });
        }
        t.startPair(t.data.maleid);
    },
    bindPickerChange: function(a) {
        this.setData({
            smaleid: a.detail.value
        });
    },
    startPair: function(a) {
        this.setData({
            maleid: this.data.smaleid
        }), this.showInfo(parseInt(this.data.maleid) + 1);
    },
    showInfo: function(a) {
        var o = this;
        t.getPairTopData(o, "xz", a, function() {
            var a = o.data.infodata;
            console.log("111", o.data.infodata), o.dealArr(a);
        });
    },
    dealArr: function(a) {
        for (var t = [], o = [], n = [], i = [], e = this, s = 0; s < a.length; s++) {
            var r = a[s];
            r.desc[0].v = r.desc[0].v.substring(0, 30) + "...", r.desc[1].v = r.desc[1].v.substring(0, 30) + "...", 
            "100" == r.exponent[0] ? t.push(r) : "90" == r.exponent[0] ? o.push(r) : "80" == r.exponent[0] ? n.push(r) : i.push(r);
        }
        setTimeout(function() {
            var a = [ t, o, n, i ];
            e.setData({
                pairList: a
            }), console.log("配对数据", e.data.pairList);
        }, 300);
    },
    scrollTop: function() {
        wx.pageScrollTo({
            scrollTop: 0,
            duration: 300
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function(a) {
        return "button" === a.from && console.log(a.target), {
            title: "星座配对排行",
            path: "/pages/pairtop_astro/pairtop_astro?maleid=" + this.data.maleid
        };
    },
    onShareTimeline(){
        return "button" === a.from && console.log(a.target), {
            title: "星座配对排行",
            path: "/pages/pairtop_astro/pairtop_astro?maleid=" + this.data.maleid
        };
    }

});